package history.hot100.simple;

import java.util.ArrayList;
import java.util.List;

// 448. 找到所有数组中消失的数字:https://leetcode-cn.com/problems/find-all-numbers-disappeared-in-an-array/
// https://leetcode-cn.com/problems/find-all-numbers-disappeared-in-an-array/solution/zhao-dao-suo-you-shu-zu-zhong-xiao-shi-d-mabl/
public class LeetCode_448 {
    public List<Integer> findDisappearedNumbers(int[] nums) {
        int n = nums.length;
        for (int num : nums) {
            int x = (num-1)%n;
            nums[x] += n;
        }
        List<Integer> result = new ArrayList<>();
        for (int i = 0; i < n; i++) {
           if (nums[i] <= n) result.add(i+1);
        }
        return result;
    }
}
